<?php

    class itClassRulesTest extends itTestCase {
        
        /**
         * @test
         */
        public function testPrefix() {
            $s = new itClassRules();
            $s->setPrefix('A');
            $this->assertEquals('A', $s->getPrefix());
        }
        
        /**
         * @test
         */
        public function testGeneral() {
            $rules = new itClassRules();
            $rules->addClass('A', 'LocationA');
            $rules->addClass('B', 'LocationB');
            $this->assertTrue($rules->hasClass('A'));
            $this->assertTrue($rules->hasClass('B'));
            $this->assertEquals('LocationA', $rules->getClass('A'));
            $this->assertEquals('LocationB', $rules->getClass('B'));
            $this->assertNull($rules->getClass('DoesNotExist'));
            $this->assertFalse($rules->hasClass('DoesNotExist'));
            $this->assertEquals(array('' => array('a' => 'LocationA', 'b' => 'LocationB')), $rules->toPersistentCache());
        }
        
        /**
         * @test
         */
        public function testGeneralNamespaces() {
            $rules = new itClassRules();
            $rules->addClass('A\B\C', 'LocationA');
            $this->assertTrue($rules->hasClass('A\B\C'));
            $this->assertEquals('LocationA', $rules->getClass('A\B\C'));
            $this->assertEquals(array('a\b' => array('c' => 'LocationA')), $rules->toPersistentCache());
        }
    }
    
?>